package Code.Objects.Characters.Enemies.Shredder;

import org.jrabbit.base.managers.ResourceManager;

import Code.Objects.Characters.Enemies.Basic.MeleeCharacter;

public class Shredder extends MeleeCharacter
{
	private double attackTimer;
	private double attackInterval;
	private float damage;

	public Shredder()
	{
		super(new ShredderSkin());
		moveSpeed = 45 + (ResourceManager.random().nextFloat() * 20);
		turnSpeed = 2.5 + (ResourceManager.random().nextFloat() * 2);
		faction = 2;
		setToCircle(25);
		defineHealth(50);

		shadowXScale = 0.45f;
		shadowYScale = 0.37f;
		shadowDarkness = 0.5f;
		shadowXOffset = 8;
		attackInterval = 10000;

		damage = 6;
		score = 10;
	}
	
	public void onCycleEnd(int cycle)
	{
		scalar.flipVertically();
	}

	public void attack(double time, double angle)
	{
		double offset = angle - rotation.angle();
		if(offset < -180)
		{
			offset += 360;
		}
		else if(offset > 180)
		{
			offset -= 360;
		}
		
		attackTimer += time;
		if(attackTimer >= attackInterval)
		{
			attackTimer -= attackInterval;

			if(Math.abs(offset) < 5)
			{
				target.damage(damage, 1);
			}
			moveForward(1000);
		}
	}
}